import request from '@/utils/request'

//分页查询菜品接口
export const getDishListAPI = (page, pageSize, name, categoryId, merchant) => {
  return request.get('/admin/dish', {
    params: {
      page, //第几页
      pageSize, //每页条数
      name, //菜品名字，用于筛选
      categoryId, //所属类别id,用于筛选
      merchant //所属商家id，用于筛选
    }
  })
}

//获取菜品详情接口
export const getDishDetailAPI = (id) => {
  return request.get(`/admin/dish/detail?id=${id}`)
}

//添加菜品接口
export const addDishAPI = (data) => {
  return request.post('/admin/dish', data)
}

//修改菜品接口
export const updateDishAPI = (data) => {
  return request.put(`/admin/dish`, data)
}

//添加菜品时获取商家下拉表数据接口
export const getMerchantSelectAPI = (merchantName) => {
  return request.get('/admin/merchant/query', {
    params: {
      merchantName
    }
  })
}

//删除菜品接口
export const deleteDishAPI = (id) => {
  return request.delete(`/admin/dish/?id=${id}`)
}

//给菜品添加材料时获取下拉菜单数据接口
export const getIngredientSelectAPI = (ingredientName) => {
  return request.get('/admin/dish/Ingredients', {
    params: {
      ingredientName // 食材名称，用于筛选
    }
  })
}

//添加菜品包含食材接口
export const addDishIngredientsAPI = (data) => {
  return request.post('/admin/dish/addIngredient', data)
}

//添加修改菜品口味接口
export const updateDishFlavorAPI = (dishId, name) => {
  return request.post(`/admin/dish/flavor`, {
    dishId,
    name
  })
}

//获取用户对该菜品的评分接口
export const getDishCommentsAPI = (params) => {
  return request.get(`/admin/dish/getUserRating`, {
    params
  })
}
